import { request } from 'umi';
import { createCRUD } from '@/utils/api';

const route = '/ide';

const crud = createCRUD<IdeEntity>(route);

export { crud };

export async function getIde(id: string) {
  return await request<IdeEntity>(`${route}/get_entity?id=${id}`, {
    method: 'GET',
  });
}

export async function startIde(id: string | undefined) {
  return await request<IdeEntity>(`${route}/start?id=${id}`, {
    method: 'GET',
  });
}

export async function stopIde(id: string | undefined) {
  return await request<IdeEntity>(`${route}/stop?id=${id}`, {
    method: 'GET',
  });
}

export async function getIdeUrl(id: string | undefined) {
  return await request<Record<string, any>>(`${route}/get_ide_url?id=${id}`, {
    method: 'GET',
  });
}
